home *** CD-ROM | disk | FTP | other *** search
/ APDL Other Worlds / APDL Other Worlds Collection.iso / SF3000 / Extras / CBlibrary / h / Loader < prev    next >
Encoding:
Text File  |  2003-09-11  |  4.1 KB  |  102 lines

  1. /*
  2.  * CBLibrary - Loader
  3.  * Copyright (C) 2003  Chris Bazley
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Lesser General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2.1 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Lesser General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Lesser General Public
  16.  * License along with this library; if not, write to the Free Software
  17.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  */
  19.  
  20. /*
  21.   The general idea of the Loader component is that it provides a much
  22.   higher-level, structured approach to data-transfer. A client
  23.   application can simply register and deregister an interest (a
  24.   'listener') for particular drop locations/file types, and a handler to
  25.   be called when data is received. 
  26.  
  27.   Two utility functions are provided: loader_buffer_file(), which
  28.   buffers a file in a flex block and loader_canonicalise(), which writes
  29.   back a pointer to a malloc block containing a canonicalised file path.
  30.  
  31.   All applications using this component need the following messages:
  32.   BadListReg, TransUXreq, LoadFail, FileNotPerm, NoSuchFileType,
  33.   NoSuchDropZone, WrongZone
  34.   
  35.   Requires toolboxlib, eventlib and flexlib
  36. */
  37.  
  38. #ifndef FlexLoader_h
  39. #define FlexLoader_h
  40.  
  41. #include <stdbool.h>
  42. #include "kernel.h"
  43. #include "flex.h"
  44. #include "toolbox.h"
  45.  
  46. /* ---------------- Client-supplied participation routines ------------------ */
  47.  
  48. typedef _kernel_oserror *(LoaderFileHandler) (char     *file_path,
  49.                                               flex_ptr  buffer);
  50.  
  51. typedef void (LoaderFinishedHandler) (char     *title,
  52.                                       bool      data_saved,
  53.                                       flex_ptr  buffer,
  54.                                       int       filetype,
  55.                                       void     *handle);
  56. /*
  57.   If 'data_saved' is set then 'title' will be the full CANONICALISED
  58.   path of the file from which the data was loaded. The case of 'title'
  59.   is not defined.
  60. */
  61.  
  62. /* --------------------------- Library functions ---------------------------- */
  63.  
  64. extern _kernel_oserror *loader_initialise(unsigned int flags);
  65.  
  66. /* Client-supplied flags for loader_initialise() */
  67. #define LOADER_IGNOREBCASTS  1  /* Ignore all DataOpen messages */
  68. #define LOADER_QUIET_BADTYPE 2  /* Suppress various errors... */
  69. #define LOADER_QUIET_BADDROP 4
  70. #define LOADER_QUIET_NOTPERM 8
  71.  
  72. extern _kernel_oserror *loader_finalise(void);
  73.  
  74. extern _kernel_oserror *loader_register_listener(
  75.                               unsigned int           flags,
  76.                               int                    file_type,
  77.                               ObjectId               drop_object,
  78.                               ComponentId           *drop_gadgets,
  79.                               LoaderFileHandler     *loader_method,
  80.                               LoaderFinishedHandler *finished_method,
  81.                               void                  *client_handle);
  82.  
  83. /* Client-supplied flags for loader_register_listener() */
  84. #define LISTENER_CLAIM       1  /* Should we also claim double-clicks */
  85. #define LISTENER_FILEONLY    2  /* Only load permanent files */
  86. #define LISTENER_SPRITEAREAS 4  /* Load sprite files as sprite areas */
  87. #define FILETYPE_ALL         -1
  88.  
  89. extern _kernel_oserror *loader_deregister_listener(int          file_type,
  90.                                                    ObjectId     drop_object,
  91.                                                    ComponentId *drop_gadgets);
  92.  
  93. /* OS_FSControl 37 with two passes */
  94. extern _kernel_oserror *loader_canonicalise(char **buffer, const char *path_var, const char *path_string, const char *file_path);
  95.  
  96. /* 'Cos we're feeling generous */
  97. extern _kernel_oserror *loader_buffer_file(const char *file_path,
  98.                                           flex_ptr     buffer,
  99.                                           bool         sprite_file);
  100.  
  101. #endif
  102.